*************************************************************************************************************
***** This file illustrates how the measure of dimension dominance applied in Section 7 of the Appendix *****
******************************* and the corresponding Table A21 were composed *******************************
*************************************************************************************************************

	* To run this file download the CHES trend file from https://www.chesdata.eu/our-surveys

*************************************************************************************************************

	/* If necessary, install missing ados.
		ssc install shapley2
	*/
	
*************************************************************************************************************
	
	* general settings
		set more off, perm
		version 16.1	
	
	use "1999-2019_CHES_dataset_means(v3).dta", clear

*************************************************************************************************************
	
			drop if eastwest == 0
			drop if year == 2019
			drop eastwest eumember cmp_id epvote eu_salience eu_dissent eu_benefit eu_ep eu_fiscal eu_intmark ///
				eu_employ eu_budgets eu_agri eu_cohesion eu_environ eu_asylum eu_foreign eu_turkey
			
			* Drop parties with missing values for vote
				/* This is somewhat unfortunate because some of these parties apperently did run: "Parties that either did not 
					run in the most recent election or did not receive enough votes to pass the threshold are coded as missing (.).
					However, since there is not way to easely distinguish the former from the latter I exclude all of them */ 
				*fre vote
					drop if vote==.
					
			numlabel, add
			tab country

		* Analysis of dimension dominance per country 1999
		
			* Belgium
				reg lrgen lrecon galtan if year==1999 & country==1
					shapley2, stat(r2)

					
			* Denmark
				reg lrgen lrecon galtan if year==1999 & country==2
					shapley2, stat(r2)
					
					
			* Germany
				reg lrgen lrecon galtan if year==1999 & country==3
					shapley2, stat(r2)
					
										
			* Greece
				reg lrgen lrecon galtan if year==1999 & country==4
					shapley2, stat(r2)
					
			* Spain
				reg lrgen lrecon galtan if year==1999 & country==5 
					shapley2, stat(r2)
					
					
			* France
				reg lrgen lrecon galtan if year==1999 & country==6
					shapley2, stat(r2)
					
					
			* Ireland
				reg lrgen lrecon galtan if year==1999 & country==7
					shapley2, stat(r2)
						
					
			* Italy
				reg lrgen lrecon galtan if year==1999 & country==8
					shapley2, stat(r2)
						
					
			* Netherlands
				reg lrgen lrecon galtan if year==1999 & country==10
					shapley2, stat(r2)
					
					
			* UK
				reg lrgen lrecon galtan if year==1999 & country==11
					shapley2, stat(r2)
						
					
			* Portugal
				reg lrgen lrecon galtan if year==1999 & country==12
					shapley2, stat(r2)
				
					
			* Austria
				reg lrgen lrecon galtan if year==1999 & country==13
					shapley2, stat(r2)
					
					
			* Finland
				reg lrgen lrecon galtan if year==1999 & country==14
					shapley2, stat(r2)
					
					
			* Sweden
				reg lrgen lrecon galtan if year==1999 & country==16
					shapley2, stat(r2)
					
					
						
		* Analysis of dimension dominance per country 2002
		
			* Belgium
				reg lrgen lrecon galtan if year==2002 & country==1
					shapley2, stat(r2)
					
					
			* Denmark
				reg lrgen lrecon galtan if year==2002 & country==2
					shapley2, stat(r2)
					
					
			* Germany
				reg lrgen lrecon galtan if year==2002 & country==3
					shapley2, stat(r2)
					
					
			* Greece
				reg lrgen lrecon galtan if year==2002 & country==4
					shapley2, stat(r2)

						
			* Spain
				reg lrgen lrecon galtan if year==2002 & country==5
					shapley2, stat(r2)
					
					
			* France
				reg lrgen lrecon galtan if year==2002 & country==6
					shapley2, stat(r2)
					
					
			* Ireland
				reg lrgen lrecon galtan if year==2002 & country==7
					shapley2, stat(r2)
					
					
			* Italy
				reg lrgen lrecon galtan if year==2002 & country==8
					shapley2, stat(r2)
					
					
			* Netherlands
				reg lrgen lrecon galtan if year==2002 & country==10
					shapley2, stat(r2)
					
					
			* UK
				reg lrgen lrecon galtan if year==2002 & country==11
					shapley2, stat(r2)
					
					
			* Portugal
				reg lrgen lrecon galtan if year==2002 & country==12
					shapley2, stat(r2)
					
					
			* Austria
				reg lrgen lrecon galtan if year==2002 & country==13
					shapley2, stat(r2)
					
					
			* Finland
				reg lrgen lrecon galtan if year==2002 & country==14
					shapley2, stat(r2)
					
					
			* Sweden
				reg lrgen lrecon galtan if year==2002 & country==16
					shapley2, stat(r2)
					

										
		* Analysis of dimension dominance per country 2006
		
			* Belgium
				reg lrgen lrecon galtan if year==2006 & country==1
					shapley2, stat(r2)
					
					
			* Denmark
				reg lrgen lrecon galtan if year==2006 & country==2
					shapley2, stat(r2)
					
					
			* Germany
				reg lrgen lrecon galtan if year==2006 & country==3
					shapley2, stat(r2)
					
										
			* Greece
				reg lrgen lrecon galtan if year==2006 & country==4
					shapley2, stat(r2)
					
						
			* Spain
				reg lrgen lrecon galtan if year==2006 & country==5
					shapley2, stat(r2)
					
					
			* France
				reg lrgen lrecon galtan if year==2006 & country==6
					shapley2, stat(r2)
					
					
			* Ireland
				reg lrgen lrecon galtan if year==2006 & country==7
					shapley2, stat(r2)
					
					
			* Italy
				reg lrgen lrecon galtan if year==2006 & country==8
					shapley2, stat(r2)
					
					
			* Netherlands
				reg lrgen lrecon galtan if year==2006 & country==10
					shapley2, stat(r2)
					
					
			* UK
				reg lrgen lrecon galtan if year==2006 & country==11
					shapley2, stat(r2)
					
					
			* Portugal
				reg lrgen lrecon galtan if year==2006 & country==12
					shapley2, stat(r2)
					
					
			* Austria
				reg lrgen lrecon galtan if year==2006 & country==13
					shapley2, stat(r2)
					
					
			* Finland
				reg lrgen lrecon galtan if year==2006 & country==14
					shapley2, stat(r2)
					
					
			* Sweden
				reg lrgen lrecon galtan if year==2006 & country==16
					shapley2, stat(r2)
					

										
		* Analysis of dimension dominance per country 2010
		
			* Belgium
				reg lrgen lrecon galtan if year==2010 & country==1
					shapley2, stat(r2)
					
					
			* Denmark
				reg lrgen lrecon galtan if year==2010 & country==2
					shapley2, stat(r2)
					
					
			* Germany
				reg lrgen lrecon galtan if year==2010 & country==3
					shapley2, stat(r2)
					
										
			* Greece
				reg lrgen lrecon galtan if year==2010 & country==4
					shapley2, stat(r2)
					
					
			* Spain
				reg lrgen lrecon galtan if year==2010 & country==5
					shapley2, stat(r2)
					
					
			* France
				reg lrgen lrecon galtan if year==2010 & country==6
					shapley2, stat(r2)
					
					
			* Ireland
				reg lrgen lrecon galtan if year==2010 & country==7
					shapley2, stat(r2)
					
					
			* Italy
				reg lrgen lrecon galtan if year==2010 & country==8
					shapley2, stat(r2)
					
					
			* Netherlands
				reg lrgen lrecon galtan if year==2010 & country==10
					shapley2, stat(r2)
					
					
			* UK
				reg lrgen lrecon galtan if year==2010 & country==11
					shapley2, stat(r2)
					
					
			* Portugal
				reg lrgen lrecon galtan if year==2010 & country==12
					shapley2, stat(r2)
					
					
			* Austria
				reg lrgen lrecon galtan if year==2010 & country==13
					shapley2, stat(r2)
					
					
			* Finland
				reg lrgen lrecon galtan if year==2010 & country==14
					shapley2, stat(r2)
					
					
			* Sweden
				reg lrgen lrecon galtan if year==2010 & country==16
					shapley2, stat(r2)
					
			
			
	* Column 5 of Table A21 simply shows the mean of the per cent estimates of these Shapley decompositions. 
	* Take Belgium as an example:

		* 1999
		reg lrgen lrecon galtan if year==1999 & country==1
			shapley2, stat(r2)
				* -> lrecon: 58.02, galtan: 41.98
		
		* 2002
		reg lrgen lrecon galtan if year==2002 & country==1
			shapley2, stat(r2)
				* -> lrecon: 55.64, galtan: 44.36
			
		* 2006
		reg lrgen lrecon galtan if year==2006 & country==1
			shapley2, stat(r2)
				* -> lrecon: 56.40, galtan: 43.60
			
		* 2010
		reg lrgen lrecon galtan if year==2010 & country==1
			shapley2, stat(r2)
				* -> lrecon: 62.37, galtan: 37.63

		display(58.02+55.64+56.40+62.37)/4 // = 58.1075
		display(41.98+44.36+43.60+37.63)/4 // = 41.8925
			/* (But note that these means only serve illustrative purposes. The regression analysis in Table A22 draws on
				the yearly values calculated above and averages them over cabinet cycles as described in section 7 of the
				appendix) */